#include <stdio.h>
#include <stdlib.h>
#include "search.h"

int sequential_search(int data[], int size, int key){
    for(int i = 0; i < size; i++){
        if(data[i] == key){
            return i;
        }
    }

    printf("no %d in the list\n",key);
    return -1;
}

int binary_search(int data[],int size, int key){
    int low = 0, high = size - 1, mid;

    while(low <= high){
        mid = (low + high) / 2;

        if(data[mid] == key){
            return mid;
        }

        if(key < data[mid]){
            high = mid -1;
        }

        if(key > data[mid]){
            low = mid + 1;
        }
    }

    printf("no %d in this list\n", key);
    return -1;
}